-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat: add DeepInfra as a model provider #7662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add DeepInfra types and model definitions - Implement DeepInfra provider handler with OpenAI-compatible API - Add dynamic model fetching from DeepInfra API - Support prompt caching for reduced costs - Update UI components to support DeepInfra selection - Add DeepInfra to router configuration Implements #7661
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed my own code and found issues. Classic me.
| ...options, | ||
| providerName: "DeepInfra", | ||
| baseURL: "https://api.deepinfra.com/v1/openai", | ||
| apiKey: options.deepInfraApiKey, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intentional? The constructor doesn't validate if the API key is provided, unlike the base class pattern used by other providers. This could lead to runtime errors when the API key is missing.
Consider adding validation:
| apiKey: options.deepInfraApiKey, | |
| if (!options.deepInfraApiKey) { | |
| throw new Error("DeepInfra API key is required") | |
| } |
|
|
||
| // For DeepInfra, we use a default model configuration | ||
| // The actual model info will be fetched dynamically via the fetcher | ||
| const defaultModelInfo: ModelInfo = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method returns hardcoded default model info instead of using actual fetched model data from the router models. Could we fetch the actual model info dynamically like OpenRouter does?
The current approach might not reflect the actual model capabilities and pricing.
|
|
||
| import type { ModelInfo } from "@roo-code/types" | ||
|
|
||
| import { parseApiPrice } from "../../../shared/cost" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This import is unused. The parseApiPrice function isn't called anywhere in this file.
| } | ||
| } | ||
| } catch (error) { | ||
| console.error(`Error fetching DeepInfra models: ${JSON.stringify(error, Object.getOwnPropertyNames(error), 2)}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error handling here uses console.error but doesn't follow the same pattern as other fetchers. Consider handling errors more gracefully without exposing the full error object structure in logs.
|
Please refer to our own PR here #7677 |
|
Closing, already added on #7677 |
Summary
This PR adds DeepInfra as a new model provider to Roo Code, enabling users to access DeepInfra's models with competitive pricing and prompt caching support.
Changes
Implementation Details
Testing
Acceptance Criteria (from #7661)
Future Improvements
Fixes #7661
Important
Add DeepInfra as a new model provider with dynamic model fetching and UI support.
DeepInfraHandlerinsrc/api/providers/deepinfra.tsfor handling DeepInfra models.BaseOpenAiCompatibleProviderto implement DeepInfra-specific logic.deepInfraSchematoprovider-settings.tsfor configuration.getDeepInfraModels()insrc/api/providers/fetchers/deepinfra.tsto fetch models dynamically from DeepInfra API.useSelectedModel()inuseSelectedModel.tsto support DeepInfra model selection.providerNamesanddynamicProvidersinprovider-settings.ts.buildApiHandler()insrc/api/index.tsfor API handler creation.validate.test.tsto include DeepInfra in mock router models.This description was created by
for 3c24584. You can customize this summary. It will automatically update as commits are pushed.